package com.edu.exam.entity.classmanagement.administrative;

// AdjustmentStatus和AdjustmentType枚举现在在同一个包中，无需import
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 行政班级调整记录实体类
 * 所属模块：F-05 行政班级管理模块
 * 对应数据库表：class_adjustment
 *
 * <p>管理行政班级结构调整的记录信息，包括调整类型、源班级、目标班级等。
 * 支持班级合并、拆分、学生调班等操作的记录管理。
 * 记录调整原因、操作人、审批状态等关键信息，提供班级调整的完整视图。</p>
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class AdministrativeClassAdjustment {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull(message = "调整类型不能为空")
    @Enumerated(EnumType.STRING)
    @Column(name = "adjustment_type", nullable = false, length = 20)
    private AdjustmentType adjustmentType;

    @Column(name = "source_class_id")
    private Long sourceClassId;

    @Column(name = "target_class_id")
    private Long targetClassId;

    @Size(max = 50, message = "学生ID长度不能超过50个字符")
    @Column(name = "student_id", length = 50)
    private String studentId;

    @NotBlank(message = "调整原因不能为空")
    @Size(max = 200, message = "调整原因长度不能超过200个字符")
    @Column(name = "adjustment_reason", nullable = false, length = 200)
    private String adjustmentReason;

    @NotNull(message = "调整时间不能为空")
    @CreatedDate
    @Column(name = "adjustment_time", nullable = false, updatable = false)
    private LocalDateTime adjustmentTime;

    @Size(max = 50, message = "调整人长度不能超过50个字符")
    @Column(name = "adjust_by", length = 50)
    private String adjustBy;

    @Size(max = 100, message = "调整人姓名长度不能超过100个字符")
    @Column(name = "adjust_by_name", length = 100)
    private String adjustByName;

    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false, length = 20)
    @Builder.Default
    private AdjustmentStatus status = AdjustmentStatus.PENDING;

    @Column(name = "approval_by", length = 50)
    private String approvalBy;

    @Column(name = "approval_time")
    private LocalDateTime approvalTime;

    @Size(max = 500, message = "审批意见长度不能超过500个字符")
    @Column(name = "approval_comment", length = 500)
    private String approvalComment;

    @Size(max = 1000, message = "调整详情长度不能超过1000字符")
    @Column(name = "adjustment_details", columnDefinition = "TEXT")
    private String adjustmentDetails;

    @Column(name = "deleted", nullable = false)
    @Builder.Default
    private Boolean deleted = false;

    @LastModifiedDate
    @Column(name = "update_time", nullable = false)
    private LocalDateTime updateTime;

    @Column(name = "version", nullable = false)
    @Builder.Default
    private Long version = 1L;
}

    
